package com.java.module.fire.service.impl;

import java.util.Collections;
import java.util.List;
import com.java.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.java.module.fire.mapper.PostMapper;
import com.java.module.fire.domain.Post;
import com.java.module.fire.service.IPostService;

/**
 * 帖子内容Service业务层处理
 * 
 * @author Administrator
 * @date 2025-02-10
 */
@Service
public class PostServiceImpl implements IPostService {
    @Autowired
    private PostMapper postMapper;

    /**
     * 查询帖子内容
     * 
     * @param postId 帖子内容ID
     * @return 帖子内容
     */
    @Override
    public Post selectPostById(Long postId) {
        return postMapper.selectPostById(postId);
    }

    /**
     * 查询帖子内容
     *
     * @param post 帖子内容
     * @return 帖子内容
     */
    @Override
    public Post selectPostOne(Post post) {
        return postMapper.selectPostOne(post);
    }

    /**
     * 查询帖子内容列表
     * 
     * @param post 帖子内容
     * @return 帖子内容
     */
    @Override
    public List<Post> selectPostList(Post post) {
        return postMapper.selectPostList(post);
    }

    /**
     * 新增帖子内容
     * 
     * @param post 帖子内容
     * @return 结果
     */
    @Override
    public int insertPost(Post post) {
        post.setCreateTime(DateUtils.getNowDate());
        return postMapper.insertPost(post);
    }

    /**
     * 修改帖子内容
     * 
     * @param post 帖子内容
     * @return 结果
     */
    @Override
    public int updatePost(Post post) {
        if(post.getIsActivity().equals(0)){
            post.setUpdateTime(DateUtils.getNowDate());
        }

        return postMapper.updatePost(post);
    }

    /**
     * 批量删除帖子内容
     * 
     * @param postIds 需要删除的帖子内容ID
     * @return 结果
     */
    @Override
    public int deletePostByIds(Long[] postIds) {
        return postMapper.deletePostByIds(postIds);
    }

    /**
     * 删除帖子内容信息
     * 
     * @param postId 帖子内容ID
     * @return 结果
     */
    @Override
    public int deletePostById(Long postId) {
        return postMapper.deletePostById(postId);
    }

    @Override
    public List<Post> selectPostListAll(Post post) {
        return postMapper.selectPostListAll(post);
    }

    @Override
    public int addLike(Post post) {
        return postMapper.addLike(post);
    }

    @Override
    public int addComment(Post post) {
        return postMapper.addComment(post);
    }

    @Override
    public Post selectPostByIdApi(Long postId) {
        return postMapper.selectPostByIdApi(postId);
    }

    @Override
    public List<Post> selectPostListUserAll(Post post) {
        return postMapper.selectPostListUserAll(post);
    }

    @Override
    public int addManualCount(Post post) {
        return postMapper.addManualCount(post);
    }
}
